package com.ruoyi.api.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SpBp3;
import com.ruoyi.system.service.ISpBp3Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 编排3Controller
 * 
 * @author ruoyi
 * @date 2022-11-12
 */
@RestController
@RequestMapping("/api/bp3")
public class SpBp3ApiController extends BaseController
{
    @Autowired
    private ISpBp3Service spBp3Service;

    /**
     * 查询编排3列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SpBp3 spBp3)
    {
        startPage();
        List<SpBp3> list = spBp3Service.selectSpBp3ListWeb(spBp3);
        return getDataTable(list);
    }

    /**
     * 导出编排3列表
     */
    @Log(title = "编排3", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SpBp3 spBp3)
    {
        List<SpBp3> list = spBp3Service.selectSpBp3ListWeb(spBp3);
        ExcelUtil<SpBp3> util = new ExcelUtil<SpBp3>(SpBp3.class);
        util.exportExcel(response, list, "编排3数据");
    }

    /**
     * 获取编排3详细信息
     */
    @GetMapping(value = "/{cj3Id}")
    public AjaxResult getInfo(@PathVariable("cj3Id") Long cj3Id)
    {
        return AjaxResult.success(spBp3Service.selectSpBp3ByCj3Id(cj3Id));
    }

    /**
     * 新增编排3
     */
    @Log(title = "编排3", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SpBp3 spBp3)
    {
        return toAjax(spBp3Service.insertSpBp3(spBp3));
    }

    /**
     * 修改编排3
     */
    @Log(title = "编排3", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SpBp3 spBp3)
    {
        return toAjax(spBp3Service.updateSpBp3(spBp3));
    }

    /**
     * 删除编排3
     */
    @Log(title = "编排3", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cj3Ids}")
    public AjaxResult remove(@PathVariable Long[] cj3Ids)
    {
        return toAjax(spBp3Service.deleteSpBp3ByCj3Ids(cj3Ids));
    }
}
